<template>
	<view class="fui-wrap">
		<view class="fui-page__bd">
			 <fui-tabs :tabs="tabsList" @change="change"  isDot scroll alignLeft/>
		</view>
		<view style="height: 1000rpx;">
			
			<z-paging ref="paging" :fixed="false"  v-model="dataList" @query="queryList" :default-page-size="10">
				<view  v-for="(item,index) in dataList" :key="index">		
				  <fui-card   :title="item.contestTitle" :tag="item.contestStatus"  @click="toCourse(item.id,item.liveSource)">
				   <view>
				   <text>{{item.contestStartTime}}</text>
				   <!-- <text>{{getTimeFromDate(item.contestEndTime)}}</text> -->
				   <text>{{item.contestNumber}}</text>
				   <text>{{item.contestAddress}}</text>
				   </view>
				    
				  </fui-card>
				  
				 
				 </view>
			</z-paging> 
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataList:[],
				queryForm:{
					 pageNum:1,
					pageSize:10,
					query:''
				},
				 tabsIndex: 0, // 控制tabs的index
				 tabsList: [{
				 name: '全部'
				 }
				 ],
			}
		},
		onLoad() {
			this.initConstTypeList();
		},
		methods: {
			toCourse(id,liveSource){
				uni.navigateTo({
					url: '/pages/views/course?contestId='+id+'&liveSource='+liveSource
				});
			},
			getTimeFromDate(dateStr) {
			
			  const parts = dateStr.split(/\s+/);  // 使用空白字符作为分隔符
			
			  const time = parts.pop(); // 移除数组中的最后一个元素，即日期部分
			  return time;
			},
			queryList(pageNo, pageSize) {
				this.queryForm.pageNum=pageNo;
				this.queryForm.pageSize=pageSize;
				 this.$request.post('contest/list',this.queryForm).then(res => {
				 	 this.$refs.paging.complete(res.data.dataList);
				 }).catch(res => {
			    	this.$refs.paging.complete(false);
			    })
			},
			change(e) {
			
				this.queryForm.query=e.index
				this.$refs.paging.reload();
			},
			initConstTypeList(){
				this.$request.get('dict/getListByType/contest_status', {}).then(res => {
				  let arr=  res.data;
				  for (let value of arr) {
					this.tabsList.push({
						name:value.dictLabel
					})
				  }
				  this.tabsList.splice(0, 1)
				})
			 
			}
		}
	}
</script>

<style>
  
</style>
